import request from '@/utils/request'

// 登录方法
export function login(username, password, code, uuid) {
  const data = {
    username,
    password,
    code,
    uuid
  }
  return request({
    url: '/login',
    headers: {
      isToken: false,
      repeatSubmit: false
    },
    method: 'post',
    data: data
  })
}

// 注册方法
export function register(data) {
  return request({
    url: '/register',
    headers: {
      isToken: false
    },
    method: 'post',
    data: data
  })
}

// 获取用户详细信息
export function getInfo() {
  // return request({
  //   url: '/getInfo',
  //   method: 'get'
  // })
  return new Promise(resolve => {
    resolve({
      "user": {
        "createBy": "admin",
        "createTime": "2023-11-10 09:10:08",
        "updateBy": null,
        "updateTime": null,
        "remark": "管理员",
        "userId": "1",
        "deptId": "103",
        "userName": "admin",
        "nickName": "111",
        "email": "111",
        "phonenumber": "2222",
        "sex": "0",
        "avatar": "",
        "password": "$2a$10$glfqhwoIR7B2z1UPHVoRUO6nTPwSFH7WACQeXousuVotfp3zbXHO2",
        "status": "0",
        "delFlag": "0",
        "loginIp": "127.0.0.1",
        "loginDate": "2024-06-12 16:04:51",
        "dept": {
          "createBy": null,
          "createTime": null,
          "updateBy": null,
          "updateTime": null,
          "remark": null,
          "deptId": "103",
          "parentId": null,
          "ancestors": null,
          "deptName": null,
          "orderNum": null,
          "leader": null,
          "phone": null,
          "email": null,
          "status": null,
          "delFlag": null,
          "parentName": null,
          "children": [],
          "oId": null,
          "displayName": null,
          "initials": null,
          "lName": null,
          "orgStyle": null,
          "parentOrgId": null,
          "displayOrder": null,
          "orgFunction": null,
          "supervisor": null,
          "orgManager": null,
          "viceManager": null,
          "erpId": null,
          "description": null
        },
        "roles": [
          {
            "createBy": null,
            "createTime": null,
            "updateBy": null,
            "updateTime": null,
            "remark": null,
            "roleId": "1",
            "roleName": "超级管理员",
            "roleKey": "admin",
            "roleSort": 1,
            "dataScope": "1",
            "menuCheckStrictly": false,
            "deptCheckStrictly": false,
            "status": "0",
            "delFlag": null,
            "flag": false,
            "menuIds": null,
            "deptIds": null,
            "permissions": null,
            "admin": true
          },
        ],
        "roleIds": null,
        "postIds": null,
        "roleId": null,
        "uId": "admin",
        "oId": "111",
        "lId": "471",
        "bossStaffId": null,
        "bossDepartId": null,
        "bossDepartName": null,
        "userType": null,
        "employeeType": null,
        "employeeNumber": null,
        "idCardNumber": null,
        "mobile": null,
        "preferredMobile": null,
        "cn": null,
        "description": null,
        "china": null,
        "workOrg": null,
        "birthday": null,
        "religionCode": null,
        "religionName": null,
        "nationCode": null,
        "nationName": null,
        "dutyCode": null,
        "dutyName": null,
        "postalAddress": null,
        "postalCode": null,
        "facsimileTelePhoneNumber": null,
        "startTime": null,
        "endTime": null,
        "passwordModifiedDate": null,
        "memberOf": null,
        "level": null,
        "levelName": null,
        "category": null,
        "functionCode": null,
        "displayOrder": null,
        "entryTime": null,
        "positionLevel": null,
        "supporterDept": null,
        "supporterCorpName": null,
        "supporterCorpContact": null,
        "superviseDept": null,
        "supervisor": null,
        "orgLevel": null,
        "userSource": "SYSTEM",
        "channelId": null,
        "channelName": null,
        "microGridId": null,
        "microGridName": null,
        "busnDeptCode": null,
        "busnDeptName": null,
        "cityId": null,
        "cityName": null,
        "msisdn": null,
        "gridId": null,
        "gridName": null,
        "admin": true
      },
      "permissions": [
        "*:*:*"
      ],
      "roles": [
        "admin"
      ]
    })
  })
}

// 退出方法
export function logout() {
  return request({
    url: '/logout',
    method: 'post'
  })
}

// 获取验证码
export function getCodeImg() {
  return request({
    url: '/captchaImage',
    headers: {
      isToken: false
    },
    method: 'get',
    timeout: 20000
  })
}
